import Ember from 'ember';
import BaseBusiness from '../base-business';

export default BaseBusiness.extend({
  queryParams: {
      id: {
          refreshModel: true
      },
      editMode: {
          refreshModel: true
      },
  },
  detailEdit:true,
  header_title:'房间信息',
  model(){
    return{};
  },
  setupController(controller, model){
    this._super(controller, model);
    var editMode=this.getCurrentController().get('editMode');
    var id=this.getCurrentController().get('id');
    if(editMode=='edit'){
      controller.set('detailEdit',false);
      this.store.findRecord('room',id).then(function(roomInfo){
        controller.set('roomInfo',roomInfo);
      });
    }else{
      controller.set('roomInfo',this.store.createRecord('room',{}));
      controller.set('detailEdit',true);
    }
    this.store.query('building',{}).then(function(buildingList){

      buildingList.forEach(function(build){
        build.set('namePinyin',pinyinUtil.getFirstLetter(build.get("name")));
      });
      controller.set('buildingList',buildingList);
    });

  }
});
